package com.ht.common.core.enums;



import com.ht.common.core.annotation.EnumDictType;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author sch
 * @version V1.0
 * @Title: SysUserCategoryEnum.java
 * @Description: 用户类型
 * @date 2022年6月13日
 */
@EnumDictType(dictType = "sys_user_category", dictName = "用户类型")
public enum SysUserCategoryEnum {
    HC("1", "货场用户"),
    BGQY("2", "报关企业用户"),
    HZQY("3", "货主企业用户"),
    CUS_USER("4", "海关用户"),
    BMHZS_USER("5", "驾驶员用户"),
    OTHER("6", "其他用户");


    /* 企业用户类型*/
    private static final List<String> ENT_LIST = Arrays.asList(BGQY.code, HZQY.code);

    private final String code;
    private final String name;

    SysUserCategoryEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 是否为企业用户
     * @author dyg
     * @date 2024/8/13 14:46
     * @param code
     * @return boolean
     */
    public static boolean isEntUser(String code) {
        return ENT_LIST.contains(code);
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static List<Map<String, String>> getDictList() {
        return Arrays.stream(SysUserCategoryEnum.values()).map(item -> {
            Map<String, String> map = new HashMap<String, String>();
            map.put("code", item.getCode());
            map.put("name", item.getName());
            return map;
        }).collect(Collectors.toList());
    }
}
